package com.olinsports.system.olinsportssystem.controller;

import com.olinsports.system.olinsportssystem.manager.MemberInformationManager;
import com.olinsports.system.olinsportssystem.model.MemberInformation;
import com.olinsports.system.olinsportssystem.model.SavingDetail;
import com.olinsports.system.olinsportssystem.service.SavingDetailService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by Administrator on 2017/7/22.
 */
@Controller
@RequestMapping("menberInfo")
public class MemberInformationController {
    @Autowired
    private MemberInformationManager memberInformationManager;


    @RequestMapping("/selectByMemberKey")
    @ResponseBody
    public MemberInformation selectByMemberKey(int memberKey){
        return memberInformationManager.selectByMemberKey(memberKey);
    }

    @RequestMapping("/listMembefInfo")
    @ResponseBody
    public Map listMembefInfo(String page, String rows,String sord, String sidx){
        return memberInformationManager.listMembefInfo(page,rows,sord,sidx);
    }

    @RequestMapping("/searchDate")
    @ResponseBody
    public Map searchDate(String page, String rows,String startDate,String endDate){
        return memberInformationManager.searchDate(rows,page,startDate,endDate);
    }

    @RequestMapping("/toDcExcel")
    @ResponseBody
    public ModelAndView toDcExcel(String startDate, String endDate, HSSFWorkbook workbook) throws Exception{

        return memberInformationManager.toDcExcel(startDate,endDate,workbook);
    }

    @RequestMapping("/searchSelf")
    @ResponseBody
    public Map searchSelf(String page, String rows,String fieldValue){
        return memberInformationManager.searchSelf(page,rows,fieldValue);
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public int saveOrUpdate(@RequestBody MemberInformation memberInformation){
        return memberInformationManager.saveOrUpdate(memberInformation);
    }

    @RequestMapping("/getSumTotal")
    @ResponseBody
    public int getSumTotal(){
        return memberInformationManager.getSumTotal();
    }

    @RequestMapping("/selectByVipNum")
    @ResponseBody
    public MemberInformation selectByVipNum(String vipNum){
        return memberInformationManager.selectByVipNum(vipNum);
    }

    @RequestMapping("/updateMmberSaving")
    @ResponseBody
    public int updateMmberSaving(@RequestBody MemberInformation memberInformation,String comment){
        System.out.println("comment = "+comment);
        return memberInformationManager.updateMmberSaving(memberInformation,comment);
    }
}
